package com.springboot.java.design.builder;

import lombok.Data;

/**
 * @Author: TongRui乀
 * @Date: 2019/3/5 15:18
 * @description： 建造者模式
 */
@Data
public class User {

    private String userName;

    private String address;

    private String gender;

    private User(String userName, String address, String gender) {
        this.userName = userName;
        this.address = address;
        this.gender = gender;
    }

    private User(){}

    public static UserBuilder userBuilder(){
        return new UserBuilder();
    }

    public static class UserBuilder{

        private String userName;

        private String address;

        private String gender;

        private UserBuilder(){}

        public UserBuilder userName(String userName){
            this.userName = userName;

            return this;
        }

        public UserBuilder address(String address){

            this.address = address;

            return this;
        }

        public UserBuilder gender(String gender){
            this.gender = gender;

            return this;
        }

        public User build(){

            User user = new User(userName, address, gender);

            return user;
        }
    }


}
